<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/4/23
 * Time: 14:20
 */

namespace app\controller\index\article;


use app\controller\index\BaseController;
use app\exception\IndexException;
use app\logic\index\article\ArticleLogic;
use app\logic\index\plan\PlanLogic;
use support\Request;
use support\Response;

class IndexController extends BaseController
{
    public function submitData(Request $request):Response
    {
        $param = [];
        $param['content'] = $request->input('content');
        $param['modelid'] = $request->input('modelid');
        $param['musicid'] = $request->input('musicid');
        $param['templateid'] = $request->input('templateid');
        $param['timbreid'] = $request->input('timbreid');
        $param['music_volume'] = $request->input('music_volume');
        $param['timbre_volume'] = $request->input('timbre_volume');
        $param['speak_speed'] = $request->input('speak_speed');
        $param['fontid'] = $request->input('fontid');
        $param['video_rate'] = $request->input('video_rate');
        if(empty($param['content'])){
            throw new IndexException(4020,'文章内容不存在');
        }
        if(empty($param['templateid'])){
            throw new IndexException(4020,'风格必选');
        }
        if(empty($param['timbreid'])){
            throw new IndexException(4020,'配音必选');
        }

        $data = ArticleLogic::getInstance()->submitData($param);

        return $this->endSuccess($data);
    }

    public function submitDataQueue(Request $request):Response
    {
        $param = [];
        $param['content'] = $request->input('content');
        $param['modelid'] = $request->input('modelid');
        $param['musicid'] = $request->input('musicid');
        $param['templateid'] = $request->input('templateid');
        $param['timbreid'] = $request->input('timbreid');
        $param['music_volume'] = $request->input('music_volume');
        $param['timbre_volume'] = $request->input('timbre_volume');
        $param['speak_speed'] = $request->input('speak_speed');
        $param['fontid'] = $request->input('fontid');
        $param['video_rate'] = $request->input('video_rate');
        if(empty($param['content'])){
            throw new IndexException(4020,'文章内容不存在');
        }
        if(empty($param['templateid'])){
            throw new IndexException(4020,'风格必选');
        }
        if(empty($param['timbreid'])){
            throw new IndexException(4020,'配音必选');
        }

        $data = ArticleLogic::getInstance()->submitDataQueue($param);

        return $this->endSuccess($data);
    }

    public function getAricleAnalyzeResult(Request $request):Response
    {
        $param = [];
        $param['id'] = $request->input('id');
        if(empty($param['id'])){
            throw new IndexException(4020,'文章内容不存在');
        }

        $data = ArticleLogic::getInstance()->getAricleAnalyzeResult($param);

        return $this->endSuccess($data);
    }

}